
<div class="container">

    <?php
    include 'member-left.php';
    include 'member-right.php';
    $filter = isset($_REQUEST["flt"]) ? $_REQUEST["flt"] : "fr";
    ?>

    <div class="member_c">
        
        <script src="/js/tabs.js" type="text/javascript"></script>
        <?php if ($member->isOwner()) { ?>
            <div id="control_dis_stream">
                <ul >
                    <li class="sub"><a <?php if ($filter == "fr" || is_numeric($filter))
            echo 'class="active"'; ?> href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>&flt=fr" ><span>Nhóm bạn</span><span class="arrow-bottom">&nbsp;</span></a>
                            <?php
                            $arrGroup = $member->getAllGroup();
                            if ($db->NumRows($arrGroup) > 0) {
                                echo '<ul >';
                                while ($row = $db->FetchToArray($arrGroup)) {
                                    ?>
                            <li><a href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>&flt=<?php echo $row['id']; ?>"><?php echo $row['group_name']; ?></a></li>
                            <?php
                        }
                        echo '</ul>';
                    }
                    ?>                        
                    </li>
                    <li><a <?php if ($filter == "cq")
                    echo 'class="active"'; ?> href="/thanh-vien?mid=<?php echo $_SESSION['client']['id']; ?>&flt=cq"><span>Cùng quê</span></a></li>
    <!--                    <li><a onclick="" href="" ><span>Theo đuôi</span></a></li>-->
                    <li><a <?php if ($filter == "" || $filter == "pr")
                            echo 'class="active"'; ?> href="/thanh-vien?mid=<?php echo $_GET['mid']; ?>&flt=pr" ><span>Cá nhân</span></a></li>
                    <li style="display:none" id="filter-feed-loading"><img style="margin-top:5px;" src="http://banbecdn.net/images/graphics/loading.gif"></li>
                </ul>
            </div>
            <div class="clear"></div>


        <?php } ?>
        <div class="tab">
            <div class="tab-sub">
                <ul class="idTabs">
                    <li><a rel="status" class="share_tab status selected" href="#tab1" id="share-status"><b><span class="icon01 ico51 inline-block">&nbsp;</span>Trạng thái</b></a></li>
                    <li><a rel="uplink" class="share_tab uplink" href="#tab2" id="share-link"><b><span class="icon01 ico31 inline-block">&nbsp;</span>Liên kết</b></a></li>
                    <li><a rel="music" class="share_tab video" href="#tab3" id="share-photo"><b><span class="icon01 ico33 inline-block">&nbsp;</span>Nhạc/Video</b></a></li>
                </ul>
                <div class="clear"></div>
            </div>

            <div class="tab-content">
                <form name="shareform" enctype="multipart/form-data" method="post" action="#">
                    <input type="hidden" value="1" id="hcurrentmodule" name="hcurrentmodule">
                    <input type="hidden" value="4" id="hfk" name="hfk">
                    <input type="hidden" value="1" id="hfkt" name="hfkt">
                    <input type="hidden" value="index" id="hcurrentaction" name="hcurrentaction">
                    <input type="hidden" value="status" id="blastType" name="blastType">
                    <input type="hidden" value="Nhận xét về liên kết này" id="blastValue" name="blastValue">

                    <div class="tab-content-main">
                        <!--Tab1-->
                        <div style="display: block;" id="tab1">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <input type="hidden" id="my_avatar" value="<?php echo $_SESSION['client']['avatar']; ?>"/>
                                <textarea id="comment" >Bạn đang nghĩ gì?</textarea>
                                <span >
                                    <input type="button" class="btnBlogComment" id="btnBlogComment" value="Chia sẻ"/>
                                </span>
                            </div>
                        </div>
                        <!--Tab2-->
                        <div style="display:none;" id="tab2">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <div id="usharelinkform" class="sub-section infosubsection" style="display: block;">
                                    <div class="sub-section-main"  >
                                        <ul>
                                            <li class="label">
                                                <h3>Liên kết:</h3>
                                            </li>
                                            <li>
                                                <input type="text" id="postLink1" class="general w350" >&nbsp;&nbsp;
                                            </li>
                                        </ul>
                                        <div class="left">

                                            <img id="imgLoadingAttachLink1" class="waiting" src="/images/waiting.gif" alt="Đang tải..." style=" display: none;"/>
                                            <input type="button" id="attach_link1" value="Duyệt" class="button">
                                        </div>
                                        <div class="clear"></div>
                                    </div>
                                    <div class="imageThumb">
                                        <div id="image-link-thumb"></div>
                                        <div style="display:none" class="btnplay"><img width="1" height="1" src="/images/blank_img.gif" alt="" class="play-btn-class"></div>
                                    </div>
                                    <div class="link-content">
                                        <div id="linkTitle" class="title" ></div>
                                        <div id="linkDescription" class="description"></div>
                                        <div class="thumb-controll">
                                            <span class="nextPre">
                                                <a  class="prev" href="javascript:;">&nbsp;</a><a  class="next" href="javascript:;">&nbsp;</a>
                                                <span id="positioncurimg">1</span> / <span id="totalimg"></span>
                                                &nbsp;Chọn hình tượng trưng<br>
                                            </span>
                                            <span class="nothumb"><input type="checkbox"  id="no-thump" name="no-thump" value=""> Không dùng hình tượng trưng</span>
                                        </div>
                                    </div>

                                    <textarea id="commentLink">Viết gì thêm đi nhỉ!</textarea>
                                    <span >
                                        <img id="imgLoadingShareLink1" src="/images/loading_small.gif" alt="Đang tải..." style="height: 30px;display: none;"/>
                                        <input type="button" class="btnBlogComment" id="btnBlogShareLink1" value="Chia sẻ" style="display: none;"/>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <!--Tab3-->
                        <div style="display: none;" id="tab3">
                            <div class="innerTab">
                                <div class="arrow-top"></div>
                                <div class="clear"></div>
                                <div id="usharelinkform" class="sub-section infosubsection" style="display: block;">
                                    <div class="sub-section-main"  style="margin-bottom: 10px">
                                        <ul>
                                            <li class="label">
                                                <h3>Mã nhúng:</h3>
                                            </li>
                                            <li>
                                                <textarea id="postEmbed" class="general w255" name="lienket" style="height: 50px" ></textarea>
                                            </li>
                                        </ul>
                                        <div class="clear"></div>
                                    </div>
                                    <textarea  id="commentEmbed">Viết gì thêm đi nhỉ!</textarea>
                                    <span >
                                        <img id="imgLoadingShareEmbed" src="/images/loading_small.gif" alt="Đang tải..." style="height: 30px;display: none;"/>
                                        <input type="button" class="btnBlogComment" id="btnBlogShareEmbed" value="Chia sẻ"/>
                                    </span>
                                </div>
                            </div>
                        </div>


                    </div>

                </form>
            </div>
        </div>
        <div class="listnews">
            <?php
            if ($member->isOwner()) {
                if ($filter == 'fr' || is_numeric($filter)) {
                    $listComment = $stream->listFriendStream($filter);
                } else if ($filter == "cq") {
                    $listComment = $stream->listFriendStream();
                } else {
                    
                    $listComment = $stream->listMyStream();
                }
                
            } else {
                
                $listComment = $stream->listMyStream();
            }

            if ($listComment['rs']) {
                ?>
                <ul id="displayBlogComment">
                    <?php
                    while ($row = $db->FetchToArray($listComment['rs'])) {

                        $last_id = $row['id'];
                        $member_info = $member->getById(intval($row['mid']));
                        $listChildComment = $stream->listChildComment($row['id']);
                        ?>
                        <li id="comment_<?php echo $row['id']; ?>">
                            <div class="divBlogCommentMain">
                                <div class="avatar1">
                                    <a href="/thanh-vien?mid=<?php echo $member_info['id']; ?>" title="<?php echo $member_info['fullname']; ?>">
                                        <img src="<?php echo $common->get_avatar_thumb($member_info['avatar']); ?>" width="50" />
                                    </a>
                                </div>
                                <div class="comment1">
                                    <p>
                                        <a href="/thanh-vien?mid=<?php echo $member_info['id']; ?>"  title="<?php echo $member_info['fullname']; ?>"><b><?php echo $member_info['fullname']; ?>:</b></a>
                                        <?php
                                        if ($row['type'] == 1) {//lien ket
                                            $arrContent = explode('$$$$$', $row['content']);
                                            echo $arrContent[4] ? $arrContent[4] . '<br >' : '<br>';
                                            if ($arrContent[0] != "" && $arrContent[0] != "undefined")
                                                echo' <a target="_blank" href="' . $arrContent[2] . '" title="' . $arrContent[1] . '" ><img src="' . $arrContent[0] . '" width="130" height="100" > </a>';
                                            echo '<span class="linktitle"><a target="_blank" href="' . $arrContent[2] . '" title="' . $arrContent[1] . '" >' . $arrContent[1] . '</a></span><span >' . $arrContent[3] . '</span>';
                                        } elseif ($row['type'] == 2) {//ma nhung
                                            $arrContentEmbed = explode('$$$$$', $row['content']);
                                            echo $arrContentEmbed[1] ? $arrContentEmbed[1] . '<div class="clear"></div>' : '<div class="clear"></div>';
                                            echo $arrContentEmbed[0];
                                        } elseif ($row['type'] == 3) {//album notify
                                            $arrAlbumNotify = explode('$$$$$', $row['content']);
                                            $rsImg = $member->getAlbumNotify($member_info['id'], $arrAlbumNotify[1]);
                                            if ($rsImg) {
                                                $AlbumNotifyContent = "";
                                                while ($rowImg = $db->FetchToArray($rsImg)) {
                                                    $AlbumNotifyContent .= "<a href=\"/thanh-vien?mid=" . $rowImg['mid'] . "&aid=" . $rowImg['aid'] . "&image_id=" . $rowImg['id'] . "&action=xemanh\"><img src=\"" . $common->get_img_thumb($rowImg['image']) . "\" /></a>";
                                                }
                                                echo " đã đã chia sẻ album <a href=\"/thanh-vien?mid=" . $member_info['id'] . "&aid=" . $arrAlbumNotify[1] . "&action=anhcuatoi\">" . $arrAlbumNotify[2] . "</a><br/>" . $AlbumNotifyContent;
                                            }
                                        } else {
                                            echo $row['content'];
                                        }
                                        ?>
                                    </p>
                                    <div class="w_100 left">

                                        <span id="like_<?php echo $row['id']; ?>" class="<?php
                                if (strpos($row['likes'], "|" . $_SESSION["client"]['id'] . "|") === false)
                                    echo 'like'; else
                                    echo 'liked';
                                        ?>" title="Thích" onclick="likeThis('<?php echo $row['id']; ?>')"></span><span class="sendDate"><?php echo $date_fomat->diff(strtotime($row['create_date'])); ?><b><a href="javascript:setFocusComment('<?php echo $row['id']; ?>');">Bình luận</a></b></span></div>
                                </div>

                            </div>
                            <!--
                            <?php
                            if (!$listChildComment['rs']) {
                                ?>
                                                                                                                                                            <div class="divPostSubCommnet">
                                                                                                                                                                <textarea id="commentCon_<?php echo $row['id']; ?>" class="commentCon" >Viết bình luận...</textarea>
                                                                                                                                                                <input class="btnBlogComment" type="button" onclick="submitChildComment(<?php echo $row['id']; ?>);" value="Chia sẻ"/>
                                                                                                                                                            </div>
                                <?php
                            }
                            ?>
                            -->
                            <?php
                            if ($listChildComment['rs']) {
                                ?>
                                <div  id="divListSubComment_<?php echo $row['id']; ?>">
                                    <?php
                                    while ($rowChild = $db->FetchToArray($listChildComment['rs'])) {
                                        $memberChildInfo = $member->getById(intval($rowChild['mid']));
                                        ?>
                                        <div id="subComment_<?php echo $rowChild['id']; ?>" class="divSubBlogComment highlight">
                                            <div class="avatar2">
                                                <a href="/thanh-vien?mid=<?php echo $memberChildInfo['id']; ?>" title="<?php echo $memberChildInfo['fullname']; ?>">
                                                    <img src="<?php echo $common->get_avatar_thumb($memberChildInfo['avatar']); ?>" width="32" />
                                                </a>
                                            </div>
                                            <div class="comment2">
                                                <a href="/thanh-vien?mid=<?php echo $memberChildInfo['id']; ?>" title="<?php echo $memberChildInfo['fullname']; ?>"><b><?php echo $memberChildInfo['fullname']; ?>:</b></a>
                                                <?php echo $rowChild['content']; ?>
                                                <br/>
                                                <div class="w_100 left ">
                                                    <span class="sendDate"><?php echo $date_fomat->diff(strtotime($rowChild['create_date'])); ?></span> <span class="like" id="like_<?php echo $rowChild['id']; ?>" title="Thích" onclick="likeThis('<?php echo $rowChild['id']; ?>')"></span>
                                                </div>
                                            </div>
                                        </div>
                                        <?php
                                    }
                                    ?>
                                    <div class="divSubBlogComment highlight"  <?php
                        if ($db->NumRows($listChildComment['rs']) == 0) {
                            echo 'style="display:none"';
                        }
                                    ?> >
                                        <textarea style="height: 16px" id="commentCon_<?php echo $row['id']; ?>" class="commentCon" >Viết bình luận...</textarea>
                                        <span class="spanSubmitComment">
                                            <input type="button" class="btnBlogComment" onclick="submitChildComment(<?php echo $row['id']; ?>);" value="Bình luận"/>
                                        </span>
                                    </div>
                                </div>
                                <?php
                            }
                            ?>
                        </li>
                        <?php
                    }
                    ?>
                </ul>
                <?php
            }
            ?>
            <input type="hidden" id="last_id" value="<?php echo $last_id; ?>"/>
            <input type="hidden" id="mid" value="<?php echo intval($_GET['mid']); ?>"/>
            <?php
            if ($db->NumRows($listComment['rs']) > 0) {
                ?>
                <div class="btnmore" ><a href="javascript:;" id="aBlogLoadMore">Xem thêm<img src="/images/down_arrow.png"></a><img src="/images/waiting.gif" id="waiting" alt="" class="waiting"></div>
                    <?php } ?>
        </div>


    </div>

</div>
<script src="/js/home.js" type="text/javascript"></script>
